﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BacteriaSimulation.Simulation
{
    public class Vector2D
    {
        public static Random random = new Random();

        public Double XComponent { get; set; }
        public Double YComponent { get; set; }

        public Vector2D(Double xComponent, Double yComponent)
        {
            this.XComponent = xComponent;
            this.YComponent = yComponent;
        }

        public static Vector2D GetRandomVector2D(Double maxSpeedComponent)
        {
            int randomSign = 1;
            randomSign = random.NextDouble() < 0.5 ? 1 : -1;
            Double xComp = random.NextDouble() * maxSpeedComponent * randomSign;
            randomSign = random.NextDouble() < 0.5 ? 1 : -1;
            Double yComp = random.NextDouble() * maxSpeedComponent * randomSign;
            Vector2D vector = new Vector2D(xComp, yComp);

            return vector;
        }

        public static Vector2D GetRandomVector2D(SimulationEnvironment env)
        {
            return GetRandomVector2D(env.MaxSpeedComponent);
        }

        public Vector2D Clone()
        {
            Vector2D clone = new Vector2D(this.XComponent, this.YComponent);
            return clone;
        }
    }
}
